package com.jeesite.modules.dp.web.yqrecord;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.dp.entity.yqrecord.DpYqrecord;
import com.jeesite.modules.dp.service.yqrecord.DpYqrecordService;

/**
 * 邀请记录Controller
 * @author hancing.com
 * @version 2024-12-16
 */
@Controller
@RequestMapping(value = "${adminPath}/dp/yqrecord/dpYqrecord")
public class DpYqrecordController extends BaseController {

	@Autowired
	private DpYqrecordService dpYqrecordService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public DpYqrecord get(String id, boolean isNewRecord) {
		return dpYqrecordService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("dp:yqrecord:dpYqrecord:view")
	@RequestMapping(value = {"list", ""})
	public String list(DpYqrecord dpYqrecord, Model model) {
		model.addAttribute("dpYqrecord", dpYqrecord);
		return "modules/dp/yqrecord/dpYqrecordList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("dp:yqrecord:dpYqrecord:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<DpYqrecord> listData(DpYqrecord dpYqrecord, HttpServletRequest request, HttpServletResponse response) {
		dpYqrecord.setPage(new Page<>(request, response));
		Page<DpYqrecord> page = dpYqrecordService.findPage(dpYqrecord);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("dp:yqrecord:dpYqrecord:view")
	@RequestMapping(value = "form")
	public String form(DpYqrecord dpYqrecord, Model model) {
		model.addAttribute("dpYqrecord", dpYqrecord);
		return "modules/dp/yqrecord/dpYqrecordForm";
	}

	/**
	 * 保存数据
	 */
	@RequiresPermissions("dp:yqrecord:dpYqrecord:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated DpYqrecord dpYqrecord) {
		dpYqrecordService.save(dpYqrecord);
		return renderResult(Global.TRUE, text("保存邀请记录成功！"));
	}
	
}